<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Point {
            // 构造函数constructor-区别于java
            constructor(x, y) {
                this.x = x;
                this.y = y
                alert(x + y);
                console.log(x + y);
            }
        }
        var point = new Point(2, 3);

        // 继承
        class Father {
            constructor() {
                this.name = "father";
                this.money = 60000;
            }
            info() {
                console.log(`${this.name} have ${this.money} money`);
            }
        }

        class Son extends Father {
            constructor() {
                super();
                this.name = "son";
                this.money = 40000;
            }
            info() {
                console.log(`${this.name} have ${this.money} money`);
            }
        }

        var father = new Father();
        father.info();
        var son = new Son();
        son.info();
    </script>
</body>

</html>